*** Settings ***
Library           RequestsLibrary
Library           ../tool/NumberTool.py
*** Variables ***
${host}           http://127.0.0.1:9000
${adminUser}      15177457696
${adminPassword}    D7BAA1BFDE966181ACFD2FD622480D87
${testUser}      rftest
${testPassword}    D7BAA1BFDE966181ACFD2FD622480D87
${scmVersion}   1.40.0
${scmReferer}   scmAppJson
${userAgent}    Apifox/1.0.0 (https://apifox.com)
${contentType}  application/json

*** Keywords ***
Save Token
    [Arguments]    ${response}
    ${token}    Set Variable    ${response.json()['data']['token']}
    ${uid}    Set Variable    ${response.json()['data']['id']}
    Set Global Variable    ${__TOKEN}    ${token}
    Set Global Variable    ${__UID}    ${uid}

Login Admin Account
    Create Session    login    ${host}
    ${data}    Create Dictionary    userName=${adminUser}    password=${adminPassword}
    ${header}    Create Default Header
    ${response}    POST On Session    login    /api/admin/account/login.ac    json=${data}    headers=${header}
    Should Be Equal As Strings    ${response.json()['data']['name']}    小马哥
    Save Token    ${response}

Login Account
    [Arguments]     ${user}        ${password}
    Create Session    login    ${host}
    ${data}    Create Dictionary    userName=${user}    password=${password}
    ${header}   Create Default Header
    ${response}    POST On Session    login    /api/admin/account/login.ac    json=${data}    headers=${header}
    Should Be Equal As Numbers    ${response.json()['status']}    200
    Save Token    ${response}
Create Default Header
    [Arguments]
    ${header}   Create Dictionary       Content-Type=${contentType}    priority=u=1, i    scm-pc-version=${scmVersion}    Qs-Referer=${scmReferer}    User-Agent=${userAgent}
    RETURN  ${header}

Create Header
    [Arguments]
    ${header}   Create Dictionary   scm-token=${__TOKEN}    scm-uid=${__UID}    Content-Type=${contentType}    priority=u=1, i    scm-pc-version=${scmVersion}    Qs-Referer=${scmReferer}    User-Agent=${userAgent}
    RETURN  ${header}

Compare Numbers Ignoring Format And Decimal Places
    [Arguments]    ${expectedNumber}    ${actualNumber}
    ${res}      Compare Numbers    ${expectedNumber}    ${actualNumber}
    Should Be True    ${res}